@use "sass:math";
@use "sass:map";

// 全局颜色函数
@function darken-color($color, $percentage) {
  @if $percentage < 0 or $percentage > 1 {
    @error "Percentage must be between 0 and 1";
  }
  @return color-mix(in srgb, $color, black math.percentage($percentage));
}

@function lighten-color($color, $percentage) {
  @if $percentage < 0 or $percentage > 1 {
    @error "Percentage must be between 0 and 1";
  }
  @return color-mix(in srgb, $color, white math.percentage($percentage));
}


// 基础按钮样式 mixin
@mixin button-base {
  position: relative;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

// 按钮尺寸 mixin
@mixin button-size($padding-y, $padding-x, $font-size, $border-radius) {
  padding: $padding-y $padding-x;
  font-size: $font-size;
  border-radius: $border-radius;
}

// 按钮变体样式 mixin
@mixin button-variant($color, $background, $border: $background) {
  color: $color;
  background: $background;
  border-color: $border;

  &:hover,
  &:focus,
  &.hover {
    background: lighten-color($background, 0.2);
    border-color: lighten-color($border, 0.2);
    color: $color;
  }

  &:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba($background, 0.5);
  }
}

// Plain 按钮变体 mixin
@mixin button-plain-variant($color) {
  color: $color;
  background: lighten-color($color, 0.9);
  
  &:hover,
  &:focus,
  &.hover {
    background: transparent;
    border-color: $color;
    color: $color;
  }
}

// 禁用状态 mixin
@mixin button-disabled($opacity) {
  cursor: not-allowed;
  opacity: $opacity;
  box-shadow: none;
  
  &:hover,
  &:focus,
  &.hover {
    cursor: not-allowed;
    opacity: $opacity;
  }
}

// Link 按钮 mixin
@mixin button-link {
  border: none;
  box-shadow: none;
  padding: 0;

  &:hover,
  &:focus,
  &.hover {
    background: transparent;
  }
  
  &:focus {
    box-shadow: none;
    text-decoration: underline;
  }
}



@mixin zoom-animation(
  $direction: 'top',
  $scaleStart: scaleY(0),
  $scaleEnd: scaleY(1),
  $origin: center top,
) {
  .zoom-in-#{$direction}-enter {
    opacity: 0;
    transform: $scaleStart;
  }
  .zoom-in-#{$direction}-enter-active {
    opacity: 1;
    transform: $scaleEnd;
    transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms, opacity 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms;
    transform-origin: $origin
  }
  .zoom-in-#{$direction}-exit {
    opacity: 1;
  }
  .zoom-in-#{$direction}-exit-active {
    opacity: 0;
    transform: $scaleStart;
    transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms, opacity 300ms cubic-bezier(0.23, 1, 0.32, 1) 100ms;
    transform-origin: $origin;
  }
}